package com.my.config;

import com.my.dao.UserDao;
import com.my.service.UserService;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 *  基于Java注解注入对象
 *  <p>
 *      <a href="https://docs.spring.io/spring-framework/reference/core/beans/java.html">Java-based Container Configuration</a>
 *  </p>
 *
 * @author: marshal
 * @date: 2023-05-15 15:53
 */
@Configuration
public class UserConfig {

    @Bean
    public UserDao userDao() {
        return new UserDao();
    }

    @Bean
    public UserService userService() {
        // 构造注入
        return new UserService(userDao());
    }
}
